// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC

.dashboard-grid {
  font-size: $fs14;
  height: 100%;
  overflow: hidden;
  overflow-y: auto;
  margin-bottom: 0;

  .grid-row {
    display: grid;
    width: 99%;
    margin-left: 13px;
  }

  .grid-item {
    align-items: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    flex: 1 0 260px;
    height: 230px;
    margin: $size-3 $size-4 $size-4 $size-2;
    position: relative;
    text-align: center;
    a {
      width: 100%;
      font-weight: normal;
    }
    @media #{$bp-max-1366} {
      height: 200px;
      flex: 1 0 230px;
    }

    &:hover {
      .grid-item-th {
        border: 2px solid $color-primary;
      }
    }

    .grid-item-th {
      border-radius: $br-small;
      border: 2px solid lighten($color-gray-20, 15%);
      text-align: initial;
    }

    &.dragged {
      border-radius: $br-small;
      border: 2px solid lighten($color-gray-20, 15%);
      text-align: initial;
      max-height: 160px;
    }

    &.placeholder {
      min-width: 115px;
      max-width: 115px;

      display: flex;
      flex-direction: column;
      justify-content: center;

      .placeholder-icon {
        svg {
          transform: rotate(-90deg);
          width: 20px;
          height: 20px;
          fill: $color-gray-30;
        }
      }

      .placeholder-label {
        font-size: $fs14;
      }
    }

    &.overlay {
      border-radius: 4px;
      border: 2px solid $color-primary;
      height: 100%;
      opacity: 0;
      pointer-events: none;
      position: absolute;
      width: 100%;
      z-index: 1;
    }

    &:hover .overlay {
      display: block;
      opacity: 1;
    }

    &.small-item {
      max-width: 12%;
      min-width: 190px;
      padding: $size-4;
      justify-content: center;
    }

    .grid-item-icon {
      width: 90px;
      height: 90px;
    }
    .info-wrapper {
      display: grid;
      grid-template-columns: 1fr auto;
    }

    .item-info {
      display: grid;
      padding: $size-2;
      text-align: left;
      width: 100%;
      font-size: $fs12;

      h3 {
        border: 1px solid transparent;
        color: $color-gray-60;
        font-size: $fs14;
        font-weight: 500;
        overflow: hidden;
        padding: 0;
        height: 27px;
        padding-right: $size-2;
        text-overflow: ellipsis;
        width: 100%;
        white-space: nowrap;
        line-height: 27px;
        max-width: 260px;
        @media #{$bp-max-1366} {
          max-width: 230px;
        }
      }

      span.date {
        color: $color-gray-30;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        white-space: nowrap;
        max-width: 260px;
        &::first-letter {
          text-transform: capitalize;
        }
        @media #{$bp-max-1366} {
          max-width: 230px;
        }
      }

      .edit-wrapper {
        .element-title {
          padding: 0px;
          height: 25px;
          color: $color-gray-60;
          font-size: $fs14;
          font-weight: 400;
        }
      }
    }

    .item-badge {
      background-color: $color-white;
      border: 1px solid $color-gray-20;
      border-radius: 2px;
      position: absolute;
      top: $size-2;
      right: $size-2;
      height: 32px;
      width: 32px;
      display: flex;
      align-items: center;
      justify-content: center;

      svg {
        fill: $color-gray-30;
        height: 16px;
        width: 16px;
      }
    }

    &.add-file {
      border: 1px dashed $color-gray-20;
      justify-content: center;
      box-shadow: none;

      span {
        color: $color-gray-60;
        font-size: $fs14;
      }

      &:hover {
        background-color: $color-white;
        border: 2px solid $color-primary;
      }
    }

    // PROJECTS, ELEMENTS & ICONS GRID
    &.project-th {
      background-color: $color-white;

      &:hover,
      &:focus,
      &:focus-within {
        .project-th-actions {
          opacity: 1;
        }
        a {
          text-decoration: none;
        }
      }

      .selected {
        .grid-item-th {
          border: 2px solid $color-primary;
        }
      }

      .project-th-actions {
        align-items: center;
        opacity: 0;
        display: flex;
        right: 5px;
        justify-content: center;
        width: 30px;
        height: 100%;

        span {
          color: $color-black;
        }

        .project-th-icon {
          align-items: center;
          display: flex;
          margin-right: $size-2;

          &.menu {
            margin-right: 0;
            display: flex;
            justify-content: center;
            align-items: flex-end;
            flex-direction: column;
            width: 100%;
            height: 30px;
            margin-top: 20px;

            > svg {
              fill: $color-gray-60;
              margin-right: 0;
              height: 18px;
              width: 18px;
            }

            &:hover,
            &:focus {
              > svg {
                fill: $color-primary-dark;
              }
            }
          }
        }
      }

      .project-th-actions.force-display {
        opacity: 1;
      }
    }

    // IMAGES SECTION
    &.images-th {
      border: 1px dashed $color-gray-20;
      border-bottom: 2px solid lighten($color-gray-20, 12%);

      &:hover {
        border-color: $color-primary;
      }
    }

    .grid-item-image {
      svg {
        max-height: 100px;
        max-width: 100px;
        min-height: 40px;
        min-width: 40px;
        width: 8vw;
      }
    }

    .color-swatch {
      border-top-left-radius: $br-medium;
      border-top-right-radius: $br-medium;
      height: 25%;
      left: 0;
      position: absolute;
      top: 0;
      width: 100%;
    }

    .color-data {
      color: $color-gray-30;
      margin-top: 15px;
    }

    .drag-counter {
      position: absolute;
      top: 5px;
      left: 4px;
      width: 32px;
      height: 32px;
      background-color: $color-primary;
      border-radius: 50%;
      color: $color-black;
      font-size: $fs18;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }

  .grid-item-th {
    background-position: center;
    background-size: auto 80%;
    background-repeat: no-repeat;
    border-top-left-radius: $br-small;
    border-top-right-radius: $br-small;
    height: 230px;
    max-height: 160px;
    overflow: hidden;
    position: relative;
    width: 100%;

    background-color: $color-canvas;
    display: flex;
    justify-content: center;
    flex-direction: row;

    .img-th {
      height: auto;
      width: 100%;
    }

    svg {
      height: 100%;
      width: 100%;
    }

    svg#loader-pencil {
      fill: $color-gray-20;
    }
  }

  // LIBRARY VIEW
  .grid-item {
    &.project-th.library {
      height: 610px;
      width: 300px;
    }

    .grid-item-th.library {
      background-color: $color-gray-50;
      flex-direction: column;
      height: 90%;
      justify-content: start;
      max-height: 550px;
      padding: $size-6;

      .asset-section {
        font-size: $fs12;
        color: $color-gray-20;

        &:not(:first-child) {
          margin-top: $size-4;
        }
      }

      .asset-title {
        display: flex;
        font-size: $fs12;
        text-transform: uppercase;

        & .num-assets {
          color: $color-gray-30;
        }
      }

      .asset-list-item {
        display: flex;
        align-items: center;
        border: 1px solid transparent;
        border-radius: $br-small;
        margin-top: $size-1;
        padding: 2px;
        font-size: $fs12;
        color: $color-white;
        position: relative;

        & .name-block {
          color: $color-gray-20;
          width: calc(100% - 24px - #{$size-2});
        }

        & .item-name {
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          display: block;
        }

        & svg {
          background-color: $color-canvas;
          border-radius: 4px;
          border: 2px solid transparent;
          height: 24px;
          width: 24px;
          margin-right: $size-2;
        }

        & .color-name {
          color: $color-white;
        }

        & .color-value {
          margin-left: $size-1;
          color: $color-gray-30;
          text-transform: uppercase;
        }

        & .typography-sample {
          height: 20px;
          margin-right: $size-1;
          width: 20px;
        }
      }
    }
  }
}

.grid-empty-placeholder {
  border-radius: $br-huge;
  display: grid;
  background-color: rgba(227, 227, 227, 0.3);
  padding: 13px;
  margin-right: 13px;
  height: 230px;
  &.loader {
    justify-items: center;
  }
  .icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  &.libs {
    background-image: url(/images/ph-left.svg), url(/images/ph-right.svg);
    background-position: 15% bottom, 85% top;
    background-repeat: no-repeat;
    align-items: center;
    border: 1px dashed #b1b2b5;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    height: 200px;
    margin: 1rem;
    padding: 3rem;
    justify-content: center;
    .text {
      p {
        max-width: 360px;
        text-align: center;
        font-size: $fs16;
      }
    }
  }
  .create-new {
    background-color: white;
    border: 2px solid $color-gray-10;
    border-radius: 3px;
    color: $color-black;
    cursor: pointer;
    height: 158px;
    font-family: "worksans", sans-serif;
    margin: 0.5rem;
    &:hover {
      border: 2px solid $color-primary;
    }
  }

  &.search {
    align-items: center;
    display: flex;
    justify-content: center;
    flex-direction: column;
    height: 200px;
    background: $color-white;
    border: 1px dashed #e3e3e3;
    border-radius: 0;
  }

  svg {
    width: 36px;
    height: 36px;
    fill: $color-gray-20;
  }

  .text {
    margin-top: 10px;
    color: $color-gray-30;
    font-size: $fs16;
  }
}
